<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>

  <script>
    /* 
    错误穿透: 失败Promise的错误穿透前面只指定了成功回调的then, 进入最下面catch的回调
      原因: then的默认失败回调为: reason => {throw reason}

      catch(onRejected) 本质是: then(value => value, onRejected)
      then(onResolved) 本质是: then(onResolved, reason => {throw reason}) 
    */
    // new Promise((resolve, reject) => {
    //   // reject(1)
    //   // throw 1
    // })
    Promise.reject(1)
      .then(value => {
        console.log('a', value)
      })
      .then(value => {
        console.log('b', value)
      })
      .catch(reason => {
        console.log('c', reason)
      })

    
     Promise.reject(1)
      .then(value => {
        console.log('a', value)
      }, reason => {throw reason})
      .then(value => {
        console.log('b', value)
      }, reason => {throw reason})
      .catch(reason => {
        console.log('c', reason)
      })
      .then(
        value => {
          console.log('d1', value)
        },
        reason => {
          console.log('d2', reason)
        }
      )
   




  </script>
</body>
</html>